package com.java.yz.day10.ketang;

/*
    String作为参数传递
    StringBuffer作为参数传递
 */
public class StringBufferText2 {
    public static void main(String[] args) {
        //String作为参数传递
        String a="hello";
        String b="world";
        System.out.println("a:"+a+"b:"+b); //a:hello b:world
        fun1(a,b);  //a:world    b:worldworld
        System.out.println("a:"+a+"b:"+b); //a:hello b:world

        //StringBuffer作为参数传递
        StringBuffer sb1 = new StringBuffer("Hello");
        StringBuffer sb2 = new StringBuffer("World");
        System.out.println("sb1:"+sb1+"sb2:"+sb2); //sb1: Hello sb2:World
        fun2(sb1,sb2);   //sb1: WorldWorld sb2:WorldWorld
        System.out.println("sb1:"+sb1+"sb2:"+sb2);  //sb1: Hello sb2:WorldWorld
    }
    public static void fun1(String a,String b){
        a=b;
        b=a+b;
        System.out.println("a:"+a+"b:"+b);
    }

    public static void fun2(StringBuffer sb1,StringBuffer sb2){
        sb1=sb2;
        sb2=sb1.append(sb2);
        System.out.println("sb1:"+sb1+"sb2:"+sb2);
    }
}
